import Vue from 'vue'
import App from './App.vue'

import router from './router/index.js'
import store from './store/index.js'

import axios from 'axios';		//路由配置

import ElementUI from 'element-ui'		//ele ui配置
import 'element-ui/lib/theme-chalk/index.css'

import VueAwesomeSwiper from 'vue-awesome-swiper';//手动轮播图
import 'swiper/css/swiper.css';
//设置代理地址
// axios.defaults.baseURL = '/api';
// 插件引用在原型上==》this.$axios

import {$get,$postKv,$postf,$postj} from'@/ajax/index2.js'
import qs from 'qs'
Vue.prototype.$axios = axios;
Vue.use(ElementUI);
Vue.use(VueAwesomeSwiper);
Vue.config.productionTip = false
axios.defaults.baseURL ="http://127.0.0.1"
Vue.prototype.$ip ="http://127.0.0.1"
Vue.prototype.$postKv=$postKv
Vue.prototype.$postf=$postf
Vue.prototype.$postj=$postj
Vue.prototype.$get=$get
Vue.prototype.$qs = qs;

Vue.use(ElementUI);
Vue.use(VueAwesomeSwiper);

Vue.prototype.$axios = axios;
axios.interceptors.request.use(config => {
		const  token =store.state.user.token;
		console.log(token);
    if (token) {  // 判断是否存在token，如果存在的话，则每个http header都加上token
      config.headers.Authorization = `Bearer ${token}`;
    }
    return config;
  },err => {
      return Promise.reject(err);
    });
  
 

  

// 注册
// Vue.use(axios);



Vue.config.productionTip = false

new Vue({
	render: h => h(App),
	// 整个实例对象，将启动路由操作
	router,
	store
	
}).$mount('#app')